﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Avaliacao.Scenes
{
    class Menu : BaseScene
    {
        protected GameButton startButton;

        public Menu(ContentManager Content, GameWindow Window): base(Content, Window)
        {
            Texture2D startTexture = Content.Load<Texture2D>("Buttons/start");
            float startX = Window.ClientBounds.Width / 2 - startTexture.Width / 2;
            float startY = Window.ClientBounds.Height / 2;

            startButton = new GameButton(startTexture, Window, new Vector2(startX, startY), 150, 50);
        }

        public override void Update(GameTime gameTime, KeyboardState keyboard, KeyboardState last_keyboard, MouseState mouse, MouseState last_mouse)
        {
            Rectangle mouseRect = new Rectangle(mouse.X, mouse.Y, 1, 1);
            startButton.setAnimation((int)GameButton.animIndexes.Still);

            if(mouseRect.Intersects(startButton.ButtonArea))
            {
                if (mouse.LeftButton == ButtonState.Released && last_mouse.LeftButton == ButtonState.Pressed)
                {
                    Game1.current_state = Game1.GameStates.IN_GAME;
                    Game1.current_level = Game1.GameLevels.LEVEL_1;
                }
                else if (mouse.LeftButton == ButtonState.Pressed)
                {
                    startButton.setAnimation((int)GameButton.animIndexes.Clicked);
                }
                else
                {
                    startButton.setAnimation((int)GameButton.animIndexes.Hover);
                }
            }
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            startButton.Draw(gameTime, spriteBatch, startButton.getAnimation());
        }
    }
}
